//
//  MKUIPickerViewCellModel.m
//  MKUI
//
//  Created by sushangjin on 15/6/18.
//  Copyright (c) 2015年 sushangjin. All rights reserved.
//

#import "MKUIPickerViewCellModel.h"
#import "MKUIPickerViewComponentModel.h"
#import "MKUIPickerViewModel.h"
#import "MKUIPickerViewCellView.h"

@implementation MKUIPickerViewCellModel
- (NSString *)description{
	return [NSString stringWithFormat:@"%@,title=%@",[super description],self.title];
}
- (id)initWithTitle:(NSString *)title{
	if (self=[super init]) {
		self.title = title;
		self.cellClass = [MKUIPickerViewCellView class];
	}
	return self;
}
- (UIPickerView *)pickerView{
	return self.pickerViewModel.pickerView;
}
- (MKUIPickerViewModel *)pickerViewModel{
	return (MKUIPickerViewModel *)[self collectionModel];
}
- (MKUIPickerViewComponentModel *)componentModel{
	return (MKUIPickerViewComponentModel *)[self sectionModel];
}
- (void)displayCell:(UIView <MKUIPickerViewCellProtocol>*)cellView{
	self.cellView = cellView;
	cellView.cellModel = self;
	[cellView setNeedsLayout];
}
- (void)didSelected:(UIPickerView *)pickerView{
	if(self.whenSelected){
		self.whenSelected(self);
	}
}
@end
